package com.fanbuchi.fukua.greendao;

import android.content.Context;

/**
 * Created by killerzhangsan on 2015/5/26.
 */
public class DBHelper{

    private static Context mContext;
    private static DBHelper instance;

    /*private CityInfoDBDao cityInfoDao;

    private DBHelper()
    {
    }

    public static DBHelper getInstance(Context context)
    {
        if (instance == null)
        {
            instance = new DBHelper();
            if (mContext == null)
            {
                mContext = context;
            }

            // 数据库对象
            DaoSession daoSession = HBApplication.getDaoSession(mContext);
            instance.cityInfoDao = daoSession.getCityInfoDBDao();
        }
        return instance;
    }

    *//** 添加数据 *//*
    public void addToCityInfoTable(CityInfo item)
    {
        cityInfoDao.insert(item);
    }

    *//** 查询 *//*
    public List<EstateLoveListJson> getCityInfoList()
    {
        QueryBuilder<CityInfo> qb = cityInfoDao.queryBuilder();
        return qb.list();
    }

    *//** 查询 *//*
    public List<CityInfo> getCityInfo()
    {
        return cityInfoDao.loadAll();// 查找图片相册
    }

    *//** 查询 *//*
    public boolean isSaved(int Id)
    {
        QueryBuilder<CityInfo> qb = cityInfoDao.queryBuilder();
        qb.where(Properties.Id.eq(Id));
        qb.buildCount().count();
        return qb.buildCount().count() > 0 ? true : false;// 查找收藏表
    }

    *//** 删除 *//*
    public void deleteCityInfoList(int Id)
    {
        QueryBuilder<CityInfo> qb = cityInfoDao.queryBuilder();
        DeleteQuery<CityInfo> bd = qb.where(Properties.Id.eq(Id)).buildDelete();
        bd.executeDeleteWithoutDetachingEntities();
    }

    *//** 删除 *//*
    public void clearCityInfo()
    {
        cityInfoDao.deleteAll();
    }

    *//** 通过城市id查找其类型id *//*
    public int getTypeId(int cityId)
    {
        QueryBuilder<CityInfo> qb = cityInfoDao.queryBuilder();
        qb.where(Properties.Id.eq(cityId));
        if (qb.list().size() > 0)
        {
            return qb.list().get(0).getTypeId();
        }
        else
        {
            return 0;
        }
    }

    *//** 多重查询 *//*
    public List<CityInfo> getIphRegionList(int cityId)
    {
        QueryBuilder<CityInfoDB> qb = cityInfoDao.queryBuilder();
        qb.where(qb.and(Properties.CityId.eq(cityId), Properties.InfoType.eq(HBContant.CITYINFO_IR)));
        qb.orderAsc(Properties.Id);// 排序依据
        return qb.list();
    }*/
}
